package com.eternal.permission.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.eternal.Exception.ResultVo;
import com.eternal.permission.entity.PermissionInfo;
import com.eternal.permission.service.PermissionInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 基础权限表 前端控制器
 * </p>
 *
 * @author Eternal
 * @since 2018-08-26
 */
@RestController
@RequestMapping("/permissionInfo")
public class PermissionInfoController {

    @Autowired
    private PermissionInfoService permissionInfoService;

    @GetMapping("/queryPermissionPage")
    @RequiresPermissions("system_permission_permission")
    public ResultVo<Page<PermissionInfo>> queryPermissionPage(@RequestParam(required = true) Integer current, @RequestParam(required = true) Integer size) {
        Page<PermissionInfo> permission = permissionInfoService.getPermission(new Page<>(current, size));
        return new ResultVo(permission);

    }

    @PostMapping("/openPermission")
    @RequiresPermissions("system_permission_permission_openPermission")
    public ResultVo<Boolean> openPermission(@RequestBody PermissionInfo permissionId) {
        System.out.println(permissionId);
        boolean openPermission = permissionInfoService.openPermission(permissionId);
        return new ResultVo<>(openPermission);

    }


}

